//
//  ExaminationTitleDate.m
//  Arts1
//
//  Created by apple on 15/9/16.
//  Copyright (c) 2015年 Arts1. All rights reserved.
//

#import "ExaminationTitleDate.h"
#import "AllHeader.h"

@implementation ExaminationTitleDate

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
       
        self.backgroundColor = kBackgroundColor;
        
        _examTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, 60, 30)];
        _examTimeLabel.font = [UIFont boldSystemFontOfSize:13];
        _examTimeLabel.textColor = [UIColor orangeColor];
        [self addSubview:_examTimeLabel];
        
        
        _provinceLabel = [[UILabel alloc] initWithFrame:CGRectMake(_examTimeLabel.right + 10, _examTimeLabel.top, 200, 20)];
        _provinceLabel.font = [UIFont boldSystemFontOfSize:13];
        _provinceLabel.textColor = kCustomColor(150, 150, 150, 1);
        [self addSubview:_provinceLabel];
        
        _addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(_provinceLabel.left, _provinceLabel.bottom + 4, _provinceLabel.width, 11)];
        _addressLabel.font = [UIFont systemFontOfSize:9];
        _addressLabel.textColor = kCustomColor(150, 150, 150, 1);
        [self addSubview:_addressLabel];
        
    }
    return self;
}


- (void)setModel:(ExaminationModel *)model
{
    _model = model;
    
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[_model.examTime intValue] - 86400];
    //格式化时间
    NSDateFormatter *formater = [[NSDateFormatter alloc] init];
    //设置格式
//    [formater setDateFormat:@"MM月dd日 HH:mm"];
    [formater setDateFormat:@"MM月dd日"];
    //获取系统的时间区域
    formater.timeZone = [NSTimeZone systemTimeZone];
    //设定本地化，时间会按照本地的习惯和文字显示日期
    formater.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en-us"];
    NSString *string = [formater stringFromDate:date];
    _examTimeLabel.text = string;
    
    _provinceLabel.text = _model.province;
    
    _addressLabel.text = _model.address;
    
}

@end
